<?php
header('Content-Type: text/html; charset=utf-8');
session_start();

if(isset($_POST['nome']))
    {
        require_once ('../../_classes/_db-conf.php');
    
        $nome = $_POST['nome'];
        $fone = $_POST['fone'];
        $email = $_POST['email'];
        $msg = $_POST['msg'];

        if($nome != '' && $msg != '')
            {
            
                $sql = "INSERT INTO contato ";
                $sql.= "(nome_con, fone_con, email_con, msg_con, data_con ) ";
                $sql.= "VALUES ('{$nome}', '{$fone}', '{$email}', '{$msg}', NOW());";
                        
                $query = new query();
                $query->exec(utf8_decode($sql));
            
                $_SESSION['aviso'] = 'sucess';
            }
        else
            {
                $_SESSION['aviso'] = 'erro';
            }
    }

session_write_close();
header("location:../../contato");
?>
